import { createPostItems } from './components/PostItem.js';
import { setupPostPopup } from './components/PostPopup.js';

// 模拟开屏加载页面
window.onload = function () {
  const loadingScreen = document.querySelector('.loading-screen');
  setTimeout(() => {
    loadingScreen.style.display = 'none';
  }, 3000);
};

// 向下滚动页面时，顶部导航栏同时滚动切换显示内容的效果
window.addEventListener('scroll', function () {
  const navbar = document.querySelector('.navbar');
  if (window.scrollY > 0) {
    navbar.classList.add('scrolled');
  } else {
    navbar.classList.remove('scrolled');
  }
});

// 渲染帖子列表
const postList = document.getElementById('post-list');
createPostItems(postList);

// 设置帖子详情弹框
setupPostPopup();
